﻿// 手机号码正则表达式
var phoneReg = /^1[345789][0-9]{9}$/;


// 功能1：向用户提示手机号码格式是否正确
phone.onblur = function(){
  var phoneValue = phone.value;
  if(!phoneReg.test(phoneValue)){
    phoneerror.innerHTML = "手机号码格式有误！";
  }else{
    phoneerror.innerHTML = "<img src='dui.png' />";
  }
};  

// 功能2：根据手机号码格式的正确性，决定是否启用验证码按钮
phone.onkeyup = function(){
  var phoneValue = phone.value;
  if(!phoneReg.test(phoneValue)){
    yanzhengmaBtn.setAttribute("disabled","disabled");
    yanzhengmaBtn.style.color = "";
  }else{
    yanzhengmaBtn.removeAttribute("disabled");
    yanzhengmaBtn.style.color = "red";
  }
};




